package IOperation;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-01-02
 * Time: 20:17
 */
public class ReturnOperation implements Operation{
    @Override

        public void work(BookList bookList) {
            System.out.println("请输入要归还的书名:");
            Scanner scanner=new Scanner(System.in);
            String name=scanner.nextLine();
            int size=bookList.getUseSize();
            for (int i = 0; i < size; i++) {
                Book book=bookList.getBook(i);
                if(book.getName().equals(name)){
                    book.setBorrowed(false);
                    System.out.println("归还成功");
                    return;
                }
            }

        }


}
